home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group92c.txt
/
000059_icon-group-sender _Thu Nov 5 10:13:58 1992.msg
< prev
next >
Wrap
Internet Message Format
|
1993-01-04
|
3KB
Received: by cheltenham.cs.arizona.edu; Thu, 5 Nov 1992 12:17:22 MST
Date: Thu, 5 Nov 92 10:13:58 EST
From: Paul_Abrahams@MTS.cc.Wayne.edu
To: icon-group@cs.arizona.edu
Message-Id: <523344@MTS.cc.Wayne.edu>
Subject: Semicolons and newlines
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
Personally, I very much like the way that Icon handles semicolons and
newlines. To appreciate it, it helps to look at some history in the
Hegelian terms of thesis, antithesis, and synthesis. (Idle query: am I
the first person to mention Hegel in this newsgroup?)
In the early days of programming languages, Fortran was dominant. The
Fortran convention is that a newline ends a statement, with an "escape
hatch" in the form of continuation cards. People generally found the
continuation cards to be an awkward and uncomfortable convention, and
also were looking for a way of placing more than one statement on a line.
That thesis--that newlines end statements, but with an escape hatch--led
to the antithesis: that newlines should be ignored altogether and that a
particular character, the semicolon, should be used either to separate
or to terminate statements. That was the approach of Algol 60, Pascal,
and their numerous successors (which did disagree on the terminator versus
separator question). That approach is still dominant today. It is
tolerable, but hardly optimal.
Icon, of course, introduced the synthesis: the idea that newlines indeed
ought to be meaningful, but that by themselves they were not sufficient
as a method of ending statements. (Let's ignore for the purposes of this
discussion the fact that Icon is an expression language.) I don't know
whether Ralph originated this idea, since it also appears in awk. It
seems to me that the synthesis has gotten it right: that newlines are too
useful to be ignored and are indeed the natural way of ending a statement,
but that we need some way of overriding the significance of newlines both
to place several statements on a single line and to allow statements to
span lines.
One drawback to the Icon approach, but an unavoidable one, is that it
is more natural to begin a continuation line with an operator than to end
the previous line with an operator. (Or so it seems to me, based perhaps
on my mathematical background; in mathematical writing, continuation
lines of equations usually begin with operators.) Another drawback in
extending the idea to other languages is that it's necessary for the
lexical scanner to be able to distinguish operators from other lexical
elements. That may not be easy in a language that allows identifiers to
be defined as operators. For example, the Icon lexical scanner has to
be able to distinguish between
x := not
+ z
and
x := knot
+ z
The second of these gets an inserted semicolon, but the first does not.
If Icon allowed me to define "knot" as an operator, it would be in trouble.
Paul Abrahams